import storage from '@/utils/storage'

export const state = {
  materialData: null
}

export const mutations = {
	SET_MATERIAL_DATA: (state, value) => {
    state.materialData = value
		storage.set('MATERIAL_DATA', value, 86400)
  },
	CLEAR_MATERIAL_DATA(state) {
		state.materialData = null
		storage.remove('MATERIAL_DATA')
	}
}

export const getters = {
	getMaterialData(state) {
	  if (state.materialData) {
	    return state.materialData
	  } else if (storage.get('MATERIAL_DATA')) {
	    return storage.get('MATERIAL_DATA')
	  }
	  return {}
	}
}
